home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / GemsII / inv_cmap / inv_cmap.3 next >
Encoding:
Text File  |  1992-06-16  |  1.7 KB  |  61 lines  |  [TEXT/MPS ]

  1. .\" -*- Text -*-
  2. .\" Copyright (c) 1990, University of Michigan
  3. .\" Template man page.  
  4. .TH INV_CMAP 3 "Month DD, YYYY" 1
  5. .UC 4 
  6. .SH NAME
  7. inv_cmap \- efficiently compute an inverse colormap
  8. .SH SYNOPSIS
  9. .HP
  10. .B
  11. void inv_cmap( colors, colormap, bits, dist_buf, rgbmap )
  12. .LP
  13. .B
  14. int colors, bits;
  15. .br
  16. .B
  17. unsigned char *colormap[3], *rgbmap;
  18. .br
  19. .B
  20. unsigned long *dist_buf;
  21. .SH DESCRIPTION
  22. .I Inv_cmap
  23. computes an inverse colormap to translate an RGB color to the nearest
  24. color in the given \fIcolormap\fP.  The arguments are
  25. .TP
  26. .I colors
  27. The number of colors in the input colormap.  Must be \(le 256.
  28. .TP
  29. .I colormap
  30. The input colormap.  The \fIi\fPth color is (\fIColormap[0][i]\fP,
  31. \fIColormap[1][i]\fP, \fIColormap[2][i]\fP).
  32. .TP
  33. .I bits
  34. Controls the size and precision of the inverse colormap.  The
  35. resulting colormap will be a cube \fI2^bits\fP on a side, and will
  36. therefore contain \fI2^(3*bits)\fP entries.  RGB colors must be
  37. quantized to \fIbits\fP bits before using the inverse colormap.
  38. .TP
  39. .I dist_buf
  40. Temporary storage used by \fIinv_cmap\fP.  It should contain at least
  41. \fI2^(3*bits)\fP elements.
  42. .TP
  43. .I rgbmap
  44. The inverse colormap.  Should be allocated with at least
  45. \fI2^(3*bits)\fP elements.  After calling \fIinv_cmap\fP, an RGB color
  46. (r,g,b) can be mapped to its closest representative in \fIcolormap\fP
  47. by evaluating
  48. .br
  49. #define quantize(p) ((p)>>(8-bits))
  50. .br
  51. rgbmap[ (((quantize(r) << bits) | quantize(g)) << bits) | quantize(b) ]
  52. .PP
  53. Predicted performance is \fIO(2^(3*bits)*log(colors))\fP.  The
  54. measured performance is sublinear (but not as good as \fIlog\fP) in
  55. the number of input colors and also in the size of the output inverse
  56. colormap. (I.e., it goes up more slowly than \fI2^(3*bits)\fP.)
  57. .SH SEE ALSO
  58. .IR colorquant (3).
  59. .SH AUTHOR
  60. Spencer W. Thomas
  61.